package com.lagou.client;

import com.lagou.model.Questions;
import com.lagou.model.Student;
import com.lagou.model.StudentMessage;

import java.util.ArrayList;
import java.util.Scanner;

public class ExamModule {
    ArrayList<Student> arrayList;

    public Questions add() {
        System.out.println("请输入题号");
        int id= ClientScanner.getScanner().nextInt();
        System.out.println("请输入题目");
        String title= ClientScanner.getScanner().next();
        System.out.println("请输入选项内容");
        String potion= ClientScanner.getScanner().next();
        System.out.println("请输入答案选项");
        String  result= ClientScanner.getScanner().next();
        return   new Questions(id,title,potion,result);
    }

    public Questions delete() {
        System.out.println("请输入要删除的题号");
        int id = ClientScanner.getScanner().nextInt();
        Questions questions = new Questions();
        questions.setTitleNum(id);
        return questions;
    }
    public Questions  findOF() {
        System.out.println("请输入要查询该学生的学号");
        int id = ClientScanner.getScanner().nextInt();
        Questions questions = new Questions();
        questions.setTitleNum(id);
        return questions ;
    }
    public Questions update() {
        System.out.println("请输入要修改的题号");
        int id= ClientScanner.getScanner().nextInt();
        System.out.println("请修改下面内容");
        System.out.println("请输入题目");
        String title= ClientScanner.getScanner().next();
        System.out.println("请输入选项内容");
        String potion= ClientScanner.getScanner().next();
        System.out.println("请输入答案选项");
        String  result= ClientScanner.getScanner().next();
        return   new Questions(id,title,potion,result);
    }
    public int examOfRun( ArrayList<Questions> list2){

        int sore=0;
        for (Questions Q:list2
        ) {
            System.out.println("题目一个为五题，每题20分");
            System.out.println("第"+Q.getTitleNum()+"题");
            System.out.println("题目为"+Q.getTitle());
            System.out.println("请选择以下正确选项："+Q.getOption());
            System.out.println("请输入你的答案");
            Scanner scanner=new Scanner(System.in);
            String s=scanner.next();
            if (s.equals(Q.getResult())){
                sore=sore+20;
                System.out.println("恭喜答对了一题");
            }

        }
      return sore;

    }
}
